package com.demo.config;

import com.demo.filter.TestFilterOne;
import com.demo.filter.TestFilterTwo;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author zhangxiangnan
 * @date 2021/8/18  23:01
 */
@Configuration
public class FilterConfig {

    @Bean
    public FilterRegistrationBean buildFilter1() {
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        filterRegistrationBean.setFilter(new TestFilterOne());
        filterRegistrationBean.setName("testFilterOne");
        filterRegistrationBean.addUrlPatterns("/*");
        filterRegistrationBean.setOrder(1);
        return filterRegistrationBean;
    }

    @Bean
    public FilterRegistrationBean buildFilter2() {
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        filterRegistrationBean.setFilter(new TestFilterTwo());
        filterRegistrationBean.setName("testFilterTwo");
        filterRegistrationBean.addUrlPatterns("/*");
        filterRegistrationBean.setOrder(2);
        return filterRegistrationBean;
    }
}
